import QtQuick 1.0

Rectangle {
    color: "transparent";

    //width: row.itemWidth; height: row.itemHeight;

    property string imgSource
    property string imgPressedSource
    property string imgDisabledSource

    property bool isEnabled: true

    property alias pressed: mouseArea.pressed
    signal buttonReleased

    Image{
        id: buttonImage
        anchors.fill: parent;
        source: imgSource;
        fillMode: "Stretch"
    }

    MouseArea{
        id: mouseArea
        anchors.fill: parent
        onClicked: if (isEnabled) buttonClicked() //ovo zovemo
        onReleased: if (isEnabled) buttonReleased()
    }

    states:[
        State{
            name: "pressed";
            when: mouseArea.pressed && isEnabled; //kad je gumb stisnut

            //kaj se onda dogadja:
            PropertyChanges {target: buttonImage; source: imgPressedSource;}
        },

        State{
            name: "normal"
            when: !mouseArea.pressed && isEnabled
            PropertyChanges {target: buttonImage; source: imgSource;}
        },

        State{
            name: "disabled"
            when: isEnabled==false
            PropertyChanges {target: buttonImage; source: imgDisabledSource;}
        }
    ]

}
